﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace TI
{
    public class StartConfig
    {
        const string defFileName = "Start.xml";

        public static StartConfig ReadConfig()
        {
            string filename = Environment.CurrentDirectory + @"\" + defFileName;
            XmlSerializer serializer = new XmlSerializer(typeof(StartConfig));
            FileStream fs = new FileStream(filename, FileMode.Open);
            StartConfig result = (StartConfig)serializer.Deserialize(fs);
            return result;

        }

        public static StartConfig config;

        public void WriteConfig()
        {
            string filename = Environment.CurrentDirectory + @"\" + defFileName;
            XmlSerializer mySerializer = new
            XmlSerializer(typeof(StartConfig));
            StreamWriter myWriter = new StreamWriter(filename);
            mySerializer.Serialize(myWriter, this);
            myWriter.Close();
        }

        public static StartConfig DefautCreateConfig()
        {
            StartConfig c = new StartConfig();
            c.TransportApp = @"C:\Temp\";
            c.WriteConfig();
            return c;
        }

        public string TransportApp { get; set; }
     
    }
}




